package com.txunda.zhuohired.aty.user.my;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ants.theantsgo.gson.GsonUtil;
import com.ants.theantsgo.util.L;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.base.BaseAty;
import com.txunda.zhuohired.bean.user.my.CareerProressDetailsBean;
import com.txunda.zhuohired.http.pst.InfoPst;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/9 10:46
 * 功能描述：进展详情
 * 联系方式：jiahuanchen@126.com
 */

public class CareerProgressDetailsAty extends BaseAty {
    /**
     * 标题
     */
    @ViewInject(R.id.tv_layout_white_center)
    private TextView tv_layout_white_center;
    /**
     * 说明
     */
    @ViewInject(R.id.tv_layout_white_right)
    private TextView tv_layout_white_right;
    /**
     * 底部按钮
     */
    @ViewInject(R.id.ll_career_progress_details_bottom)
    private LinearLayout ll_career_progress_details_bottom;
    /**
     * 底部左侧按钮
     */
    @ViewInject(R.id.tv_career_progress_details_left)
    private TextView tv_career_progress_details_left;
    /**
     * 底部右侧按钮
     */
    @ViewInject(R.id.tv_career_progress_details_right)
    private TextView tv_career_progress_details_right;
    /**
     * 底部文字
     */
    @ViewInject(R.id.tv_career_progress_details_take)
    private TextView tv_career_progress_details_take;
    /**
     * 已申请
     */
    @ViewInject(R.id.ll_career_progress_details_apply)
    private LinearLayout ll_career_progress_details_apply;
    /**
     * 未获得面试机会
     */
    @ViewInject(R.id.ll_career_progress_next)
    private LinearLayout ll_career_progress_next;
    /**
     * 已获得面试机会
     */
    @ViewInject(R.id.ll_career_progress_chance)
    private LinearLayout ll_career_progress_chance;
    /**
     * 职位名称
     */
    @ViewInject(R.id.tv_detail_title)
    private TextView tv_detail_title;
    /**
     * 公司名称
     */
    @ViewInject(R.id.tv_detail_name)
    private TextView tv_detail_name;

    /**
     * 面试日期
     */
    @ViewInject(R.id.tv_face_time)
    private TextView tv_face_time;

    /**
     * 面试时间
     */
    @ViewInject(R.id.tv_face_clock)
    private TextView tv_face_clock;

    /**
     * 面试地址
     */
    @ViewInject(R.id.iv_detail_address)
    private TextView iv_detail_address;

    /**
     * 备注
     */
    @ViewInject(R.id.tv_detial_desc)
    private TextView tv_detial_desc;

    /**
     * 申请时间
     */
    @ViewInject(R.id.tv_detial_create_time)
    private TextView tv_detial_create_time;

    /**
     * 工作薪资
     */
    @ViewInject(R.id.tv_detail_money)
    private TextView tv_detail_money;
    /**
     * 改变状态时间
     */
    @ViewInject(R.id.tv_huoqu_jihui_time)
    private TextView tv_huoqu_jihui_time;
    /**
     * 没有获得面试  时间
     */
    @ViewInject(R.id.tv_update_time_none)
    private TextView tv_update_time_none;

    private CareerProressDetailsBean careerProressDetailsBean;
    private InfoPst infoPst;
    private String token;

    private String type = "0";
    private String status;
    private String id;
    private int flag = 1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.layout_white_head);
        tv_layout_white_center.setText("进展详情");
        tv_layout_white_right.setVisibility(View.VISIBLE);
        tv_layout_white_right.setText("说明");
    }

    @Override
    @OnClick({R.id.tv_career_progress_details_right, R.id.tv_career_progress_details_left})
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.tv_career_progress_details_right:
                flag = 2;
                initBottomChange();
                break;
            case R.id.tv_career_progress_details_left:

                break;
        }
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_career_progress_details;
    }

    @Override
    protected void initialized() {
        type = getIntent().getStringExtra("status_type");
        status = getIntent().getStringExtra("status");
        infoPst = new InfoPst(this);
        token = application.getUserInfo().get("data");
        id = getIntent().getStringExtra("id");

    }

    @Override
    protected void requestData() {
        infoPst.jobMarchInfo(token, id);
//        initBottomChange();
    }

    private void initBottomChange() {
//        if ("2".equals(type)) {//申请成功
//            ll_career_progress_details_bottom.setVisibility(View.VISIBLE);
//            ll_career_progress_details_apply.setVisibility(View.VISIBLE);
//            ll_career_progress_chance.setVisibility(View.GONE);
//            ll_career_progress_next.setVisibility(View.GONE);
//            tv_career_progress_details_left.setText("取消申请");
//            tv_career_progress_details_right.setText("立即沟通");
//            tv_career_progress_details_take.setVisibility(View.GONE);
//            tv_detial_create_time.setText(careerProressDetailsBean.getData().getCreate_time());
//        } else if ("1".equals(type)) {//全部
            if (status.equals("1")) {//申请成功
                ll_career_progress_details_bottom.setVisibility(View.VISIBLE);
                ll_career_progress_details_apply.setVisibility(View.VISIBLE);
                ll_career_progress_chance.setVisibility(View.GONE);
                ll_career_progress_next.setVisibility(View.GONE);
                tv_career_progress_details_left.setText("取消申请");
                tv_career_progress_details_right.setText("立即沟通");
                tv_career_progress_details_take.setVisibility(View.GONE);
                tv_detial_create_time.setText(careerProressDetailsBean.getData().getCreate_time());
            } else if (status.equals("4 ")) {//拒绝邀请
                ll_career_progress_details_bottom.setVisibility(View.GONE);
                ll_career_progress_next.setVisibility(View.VISIBLE);
                ll_career_progress_details_apply.setVisibility(View.GONE);
                ll_career_progress_chance.setVisibility(View.GONE);
                tv_detial_create_time.setText(careerProressDetailsBean.getData().getCreate_time());
                tv_update_time_none.setText(careerProressDetailsBean.getData().getUpdate_time());
            } else {//面试申请
                ll_career_progress_details_bottom.setVisibility(View.VISIBLE);
                ll_career_progress_chance.setVisibility(View.VISIBLE);
                ll_career_progress_next.setVisibility(View.GONE);
                ll_career_progress_details_apply.setVisibility(View.GONE);
                if (flag == 1) {
                    tv_career_progress_details_left.setText("拒绝面试");
                    tv_career_progress_details_right.setText("接受面试");
                    tv_career_progress_details_take.setVisibility(View.GONE);
                    tv_face_time.setText(careerProressDetailsBean.getData().getFace_time());
                    tv_face_clock.setText(careerProressDetailsBean.getData().getFace_clock());
                    iv_detail_address.setText(careerProressDetailsBean.getData().getAddress());
                    tv_detial_desc.setText(careerProressDetailsBean.getData().getDesc());
                    tv_detial_create_time.setText(careerProressDetailsBean.getData().getCreate_time());
                    tv_huoqu_jihui_time.setText(careerProressDetailsBean.getData().getUpdate_time());

                }
            }
//        } else if ("3".equals(type)) {//拒绝面试
//            ll_career_progress_details_bottom.setVisibility(View.GONE);
//            ll_career_progress_next.setVisibility(View.VISIBLE);
//            ll_career_progress_details_apply.setVisibility(View.GONE);
//            ll_career_progress_chance.setVisibility(View.GONE);
//            tv_detial_create_time.setText(careerProressDetailsBean.getData().getCreate_time());
//            tv_update_time_none.setText(careerProressDetailsBean.getData().getUpdate_time());
//
//
//        } else if ("4".equals(type)) {//面试邀请
//            ll_career_progress_details_bottom.setVisibility(View.VISIBLE);
//            ll_career_progress_chance.setVisibility(View.VISIBLE);
//            ll_career_progress_next.setVisibility(View.GONE);
//            ll_career_progress_details_apply.setVisibility(View.GONE);
//            if (flag == 1) {
//                tv_career_progress_details_left.setText("拒绝面试");
//                tv_career_progress_details_right.setText("接受面试");
//                tv_career_progress_details_take.setVisibility(View.GONE);
//                tv_face_time.setText(careerProressDetailsBean.getData().getFace_time());
//                tv_face_clock.setText(careerProressDetailsBean.getData().getFace_clock());
//                iv_detail_address.setText(careerProressDetailsBean.getData().getAddress());
//                tv_detial_desc.setText(careerProressDetailsBean.getData().getDesc());
//                tv_detial_create_time.setText(careerProressDetailsBean.getData().getCreate_time());
//                tv_huoqu_jihui_time.setText(careerProressDetailsBean.getData().getUpdate_time());
//
//
//            }
//
//        }
    }

    @Override
    public void onComplete(String requestUrl, String jsonStr) {
        super.onComplete(requestUrl, jsonStr);
        if (requestUrl.contains("jobMarchInfo")) {
            L.e("====jobMarchInfo====", jsonStr);
            careerProressDetailsBean = GsonUtil.GsonToBean(jsonStr, CareerProressDetailsBean.class);

            tv_detail_title.setText(careerProressDetailsBean.getData().getTitle());

            tv_detail_name.setText(careerProressDetailsBean.getData().getName());

            tv_detail_money.setText(careerProressDetailsBean.getData().getPrice());
            initBottomChange();
        }
    }


}
